<div class="panel panel-default">
  <div class="panel-heading">
    <div class="pull-right">
      {% if canManage %}
        <a href="#modal" data-toggle="modal" data-url="{{ path('course_announcement_add',{courseId:course.id}) }}" class="btn btn-link btn-xs"><span class="glyphicon glyphicon-plus"></span> 添加公告</a>
      {% endif %}
    </div>
  	<h3 class="panel-title">课程公告</h3>
  </div>

  <div class="panel-body">
    <ul class="media-list announcement-list">
      {% for announcement in announcements %}
        <li class="media">
          <div class="media-body">
            <p>
              {% if canTake %}
                <a id="course-buy-btn" href="#modal" data-toggle="modal" data-url="{{ path('course_announcement_show', {courseId:course.id, id:announcement.id}) }}" >{{ announcement.content|plain_text(40)|default('<span class="text-warning">(请点击查看)</span>')|raw }}</a>
              {% else %}
                <a id="course-buy-btn" href="#modal" data-toggle="modal" data-url="{{ path('course_buy', {id:course.id}) }}" >{{ announcement.content|plain_text(40)|default('<span class="text-warning">(请点击查看)</span>')|raw }}</a>
              {% endif %}
            </p>

            {% if canManage %}
              <div class="clearfix">
                <span class="pull-right text-muted text-sm">{{ announcement.createdTime|date('Y-m-d H:i') }}</span>
                <a class="text-muted text-sm mrm action" href="javascript:;" data-target="#modal"  data-toggle="modal" data-url="{{ path('course_announcement_update',{courseId:course.id, id:announcement.id}) }}"><span class="glyphicon glyphicon-pencil"></span> 修改</a>
                <a class="text-muted text-sm action" href="#" data-role="delete" data-url="{{ path('course_announcement_delete',{courseId:course.id, id:announcement.id}) }}"><span class="glyphicon glyphicon-trash"></span> 删除</a>
              </div>

            {% endif %}
          </div>
        </li>
      {% else %}
        <li class="empty">暂无公告</li>
      {% endfor %}
    </ul>
  </div>
</div>